package com.swiftops.common.util;

import cn.hutool.core.lang.generator.SnowflakeGenerator;

import java.util.UUID;

/**
 * 唯一性ID工具类
 */
public class IdGen {

    public static final SnowflakeGenerator SNOWFLAKE_GENERATOR = new SnowflakeGenerator();

    /**
     * 封装JDK自带的UUID, 通过Random数字生成, 中间无-分割.
     */
    public synchronized static String uuid() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    //雪花算法ID
    public static String next() {
        String id = SNOWFLAKE_GENERATOR.next().toString();
        return id;
    }
}
